/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * criaContracto.java
 *
 * Created on Jan 9, 2010, 4:11:06 PM
 */

/**
 *
 * @author Pedro
 */

package gcs.Interface;

import gcs.Negocio.TipoServico;
import gcs.Negocio.Contracto;
import gcs.Negocio.Empresa;
import gcs.Negocio.Actividade;
import gcs.Negocio.Servico;
import java.util.GregorianCalendar;
import java.util.TreeMap;
import javax.swing.DefaultListModel;


public class criaContracto extends javax.swing.JFrame {
    //variaveis
    String codCli;
    GCSView gcsv;
    GCS gcs;
    /** Creates new form criaContracto */
    public criaContracto(String cod_cli, GCSView gv) {
        initComponents();
        gcs = new GCS();
        gcsv=gv;
        codCli = cod_cli;
        preencheComboPrest();
        preencheComboTipoServ();
        jComboBox_tipoServActionPerformed(null);
        jComboBox_servicosActionPerformed(null);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jComboBox_tipoServ = new javax.swing.JComboBox();
        jLabel_tipoServCriaCont = new javax.swing.JLabel();
        jLabel_servCriaCont = new javax.swing.JLabel();
        jComboBox_servicos = new javax.swing.JComboBox();
        jLabel_prestCriaCont = new javax.swing.JLabel();
        jComboBox_prestacoes = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList_actividades = new javax.swing.JList();
        jButton_cancelar = new javax.swing.JButton();
        jButton_continuar = new javax.swing.JButton();
        jLabel_lAct = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel_nome = new javax.swing.JLabel();
        jTextField_nome = new javax.swing.JTextField();
        jLabel_desc = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea_desc = new javax.swing.JTextArea();
        jLabel_preco = new javax.swing.JLabel();
        jTextField_preco = new javax.swing.JTextField();
        jLabel_euros = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        openMenuItem = new javax.swing.JMenuItem();
        saveMenuItem = new javax.swing.JMenuItem();
        saveAsMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();
        cutMenuItem = new javax.swing.JMenuItem();
        copyMenuItem = new javax.swing.JMenuItem();
        pasteMenuItem = new javax.swing.JMenuItem();
        deleteMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        contentsMenuItem = new javax.swing.JMenuItem();
        aboutMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(criaContracto.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        jComboBox_tipoServ.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox_tipoServ.setName("jComboBox_tipoServ"); // NOI18N
        jComboBox_tipoServ.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jComboBox_tipoServMouseClicked(evt);
            }
        });
        jComboBox_tipoServ.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboBox_tipoServItemStateChanged(evt);
            }
        });
        jComboBox_tipoServ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox_tipoServActionPerformed(evt);
            }
        });

        jLabel_tipoServCriaCont.setText(resourceMap.getString("jLabel_tipoServCriaCont.text")); // NOI18N
        jLabel_tipoServCriaCont.setName("jLabel_tipoServCriaCont"); // NOI18N

        jLabel_servCriaCont.setText(resourceMap.getString("jLabel_servCriaCont.text")); // NOI18N
        jLabel_servCriaCont.setName("jLabel_servCriaCont"); // NOI18N

        jComboBox_servicos.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox_servicos.setName("jComboBox_servicos"); // NOI18N
        jComboBox_servicos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox_servicosActionPerformed(evt);
            }
        });
        jComboBox_servicos.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jComboBox_servicosFocusLost(evt);
            }
        });

        jLabel_prestCriaCont.setText(resourceMap.getString("jLabel_prestCriaCont.text")); // NOI18N
        jLabel_prestCriaCont.setName("jLabel_prestCriaCont"); // NOI18N

        jComboBox_prestacoes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox_prestacoes.setName("jComboBox_prestacoes"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jList_actividades.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jList_actividades.setName("jList_actividades"); // NOI18N
        jList_actividades.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jList_actividadesValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(jList_actividades);

        jButton_cancelar.setIcon(resourceMap.getIcon("jButton_cancelar.icon")); // NOI18N
        jButton_cancelar.setText(resourceMap.getString("jButton_cancelar.text")); // NOI18N
        jButton_cancelar.setName("jButton_cancelar"); // NOI18N
        jButton_cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_cancelarActionPerformed(evt);
            }
        });

        jButton_continuar.setIcon(resourceMap.getIcon("jButton_continuar.icon")); // NOI18N
        jButton_continuar.setText(resourceMap.getString("jButton_continuar.text")); // NOI18N
        jButton_continuar.setName("jButton_continuar"); // NOI18N
        jButton_continuar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_continuarActionPerformed(evt);
            }
        });

        jLabel_lAct.setText(resourceMap.getString("jLabel_lAct.text")); // NOI18N
        jLabel_lAct.setName("jLabel_lAct"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel_nome.setText(resourceMap.getString("jLabel_nome.text")); // NOI18N
        jLabel_nome.setName("jLabel_nome"); // NOI18N

        jTextField_nome.setEditable(false);
        jTextField_nome.setName("jTextField_nome"); // NOI18N

        jLabel_desc.setText(resourceMap.getString("jLabel_desc.text")); // NOI18N
        jLabel_desc.setName("jLabel_desc"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jTextArea_desc.setColumns(10);
        jTextArea_desc.setEditable(false);
        jTextArea_desc.setRows(3);
        jTextArea_desc.setBorder(null);
        jTextArea_desc.setHighlighter(null);
        jTextArea_desc.setName("jTextArea_desc"); // NOI18N
        jScrollPane2.setViewportView(jTextArea_desc);

        jLabel_preco.setText(resourceMap.getString("jLabel_preco.text")); // NOI18N
        jLabel_preco.setName("jLabel_preco"); // NOI18N

        jTextField_preco.setEditable(false);
        jTextField_preco.setName("jTextField_preco"); // NOI18N

        jLabel_euros.setText(resourceMap.getString("jLabel_euros.text")); // NOI18N
        jLabel_euros.setName("jLabel_euros"); // NOI18N

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setName("fileMenu"); // NOI18N

        openMenuItem.setName("openMenuItem"); // NOI18N
        fileMenu.add(openMenuItem);

        saveMenuItem.setName("saveMenuItem"); // NOI18N
        fileMenu.add(saveMenuItem);

        saveAsMenuItem.setName("saveAsMenuItem"); // NOI18N
        fileMenu.add(saveAsMenuItem);

        exitMenuItem.setName("exitMenuItem"); // NOI18N
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        editMenu.setName("editMenu"); // NOI18N

        cutMenuItem.setName("cutMenuItem"); // NOI18N
        editMenu.add(cutMenuItem);

        copyMenuItem.setName("copyMenuItem"); // NOI18N
        editMenu.add(copyMenuItem);

        pasteMenuItem.setName("pasteMenuItem"); // NOI18N
        editMenu.add(pasteMenuItem);

        deleteMenuItem.setName("deleteMenuItem"); // NOI18N
        editMenu.add(deleteMenuItem);

        menuBar.add(editMenu);

        helpMenu.setName("helpMenu"); // NOI18N

        contentsMenuItem.setName("contentsMenuItem"); // NOI18N
        helpMenu.add(contentsMenuItem);

        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(jLabel_prestCriaCont)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jComboBox_prestacoes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(layout.createSequentialGroup()
                        .add(jLabel_servCriaCont)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jComboBox_servicos, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(layout.createSequentialGroup()
                        .add(jLabel_tipoServCriaCont)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jComboBox_tipoServ, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(790, Short.MAX_VALUE))
            .add(layout.createSequentialGroup()
                .add(35, 35, 35)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel_lAct)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 144, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(layout.createSequentialGroup()
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel_desc))
                        .add(layout.createSequentialGroup()
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jTextField_nome, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE))
                        .add(layout.createSequentialGroup()
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jLabel_nome)
                                .add(jLabel4))
                            .add(253, 253, 253))
                        .add(layout.createSequentialGroup()
                            .add(jTextField_preco, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 58, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jLabel_euros)
                            .add(231, 231, 231))
                        .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE)))
                    .add(layout.createSequentialGroup()
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jLabel_preco)))
                .add(1, 1, 1)
                .add(jButton_cancelar)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jButton_continuar)
                .add(107, 107, 107))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel_prestCriaCont)
                    .add(jComboBox_prestacoes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jComboBox_tipoServ, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel_tipoServCriaCont))
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jComboBox_servicos, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel_servCriaCont))
                        .add(32, 32, 32)
                        .add(jLabel_lAct)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 211, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(layout.createSequentialGroup()
                        .add(jLabel4)
                        .add(11, 11, 11)
                        .add(jLabel_nome)
                        .add(4, 4, 4)
                        .add(jTextField_nome, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jLabel_desc)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jLabel_preco)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jTextField_preco, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel_euros))))
                .addContainerGap(32, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap(371, Short.MAX_VALUE)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton_cancelar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 38, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jButton_continuar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void jList_actividadesValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList_actividadesValueChanged
        if(jList_actividades.getSelectedIndex()!=-1){
            //parse do codigo da actividade
            String cod = parse_cod(jList_actividades.getSelectedValue().toString());
            Actividade a = ((Servico)jComboBox_servicos.getSelectedItem()).getActividades().get(cod);
            //inserir descricoes
            jTextField_nome.setText(a.getNome());
            jTextArea_desc.setText(a.getDesc());
            jTextField_preco.setText(a.getPreco()+"");
        }
    }//GEN-LAST:event_jList_actividadesValueChanged

    private void jComboBox_tipoServActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox_tipoServActionPerformed
        if( jComboBox_tipoServ.getSelectedItem()!=null){
            jComboBox_servicos.removeAllItems();
            //System.out.println("AKI["+jComboBox_tipoServ.getSelectedItem()+"]"+((TipoServico)jComboBox_tipoServ.getSelectedItem()).toString());
            for(Empresa e : GCS.getEmpresas().values()){
                
                if(e.getActivo()==true && e.getTipo()==((TipoServico)jComboBox_tipoServ.getSelectedItem()).getCod())
                    for(Servico s : e.getServicos().values())
                        if(s.getActivo()==true && s.getActividades().size()!=0)
                            jComboBox_servicos.addItem(s);
                    }
            jComboBox_servicosActionPerformed(null);
        }

    }//GEN-LAST:event_jComboBox_tipoServActionPerformed

    private void jComboBox_servicosFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboBox_servicosFocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBox_servicosFocusLost

    private void jComboBox_tipoServMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jComboBox_tipoServMouseClicked

}//GEN-LAST:event_jComboBox_tipoServMouseClicked

    private void jComboBox_tipoServItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBox_tipoServItemStateChanged

}//GEN-LAST:event_jComboBox_tipoServItemStateChanged

    private void jComboBox_servicosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox_servicosActionPerformed
        if(jComboBox_servicos.getSelectedItem()!=null){
            DefaultListModel model_actividades = new DefaultListModel();
            for(Actividade a : ((Servico)jComboBox_servicos.getSelectedItem()).getActividades().values())
                model_actividades.addElement(a.getcodAct()+": "+a.getNome());
            jList_actividades.setModel(model_actividades);
            jList_actividades.setSelectedIndex(0);
            jList_actividadesValueChanged(null);
        }
}//GEN-LAST:event_jComboBox_servicosActionPerformed

    private void jButton_cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_cancelarActionPerformed
        this.dispose();
        gcsv.EnableTrue();
        gcsv.detalhes_tab2(false);
    }//GEN-LAST:event_jButton_cancelarActionPerformed

    private void jButton_continuarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_continuarActionPerformed
        int prest = ((Integer)jComboBox_prestacoes.getSelectedItem());
        String codServ = ((Servico)jComboBox_servicos.getSelectedItem()).getcodServ();
        String codEmp="";
        for(Empresa emp : GCS.getEmpresas().values())
            if(emp.getServicos().get(codServ)!=null)
                codEmp = emp.getCodEmp();
        Contracto cont = new Contracto(codCli, GCS.getUtilizadorLoggado().getUser(), codEmp, new GregorianCalendar(), true, new TreeMap<String,Actividade>(), codServ, prest);
        AddAct_Contr a = new AddAct_Contr(cont,gcsv,0);
        a.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton_continuarActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                //new criaContracto().setVisible(true);
            }
        });
    }

    private String parse_cod(String cod){
        String clean = "";
        String[] strs;
        strs = cod.split(":");
        clean = strs[0];
        return clean;
    }
    //preencher prestaçoes
    private void preencheComboPrest(){
        jComboBox_prestacoes.removeAllItems();
        jComboBox_prestacoes.addItem(1);
        jComboBox_prestacoes.addItem(2);
        jComboBox_prestacoes.addItem(3);
    }
    //preencher tipos serv
    private void preencheComboTipoServ(){
        jComboBox_tipoServ.removeAllItems();
        for(TipoServico tp : GCS.getTipoServico().values())
            jComboBox_tipoServ.addItem(tp);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JMenuItem contentsMenuItem;
    private javax.swing.JMenuItem copyMenuItem;
    private javax.swing.JMenuItem cutMenuItem;
    private javax.swing.JMenuItem deleteMenuItem;
    private javax.swing.JMenu editMenu;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JButton jButton_cancelar;
    private javax.swing.JButton jButton_continuar;
    private javax.swing.JComboBox jComboBox_prestacoes;
    private javax.swing.JComboBox jComboBox_servicos;
    private javax.swing.JComboBox jComboBox_tipoServ;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel_desc;
    private javax.swing.JLabel jLabel_euros;
    private javax.swing.JLabel jLabel_lAct;
    private javax.swing.JLabel jLabel_nome;
    private javax.swing.JLabel jLabel_preco;
    private javax.swing.JLabel jLabel_prestCriaCont;
    private javax.swing.JLabel jLabel_servCriaCont;
    private javax.swing.JLabel jLabel_tipoServCriaCont;
    private javax.swing.JList jList_actividades;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextArea jTextArea_desc;
    private javax.swing.JTextField jTextField_nome;
    private javax.swing.JTextField jTextField_preco;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem openMenuItem;
    private javax.swing.JMenuItem pasteMenuItem;
    private javax.swing.JMenuItem saveAsMenuItem;
    private javax.swing.JMenuItem saveMenuItem;
    // End of variables declaration//GEN-END:variables

}
